home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: prefix vs. postfix
- Date: Thu, 04 Jan 1996 01:32:21 GMT
- Organization: Netcom
- Message-ID: <30eb2dec.9255744@nntp.ix.netcom.com>
- References: <4c1089$gro@nntpd2.cxo.dec.com> <tcpnntpd.15.12.30.11.27.18.2781597121.305087@the-fix.sos.on.ca> <30DEC199514333959@erich.triumf.ca> <4cf35v$7il@head.globalcom.net>
- NNTP-Posting-Host: ix-dc11-10.ix.netcom.com
- X-NETCOM-Date: Wed Jan 03 5:30:45 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- scicom@globalcom.net (stephen j beaver) wrote:
-
- |><SNIP>
- |>
- |>>The two operators _never_ do the same thing. However, if you just
- want the
- |>>side effect of the increment, but the value returned by i++ or ++i
- is not used,
- |>>(as in for(i = 0; i < 10; i++) ) it doesn't matter which is used.
- |>
- |>I thought that:
- |>
- |>for(i=0;i<10;i++)
- |> {
- |> loopbody(i):
- |> }
- |>
- |>Increments i after the loop so that the first value passed to
- loopbody() is zero, whereas:
- |>
- |>for(i=0;i<10;++i)
- |> {
- |> loopbody();
- |> }
- |>
- |>increments i before the loop body so that the first value passedtp
- loopbody() is 1 in this case.
- |>
- |>No?
-
- No. Both do the incrementation at the end of the loop. The
- reinitialization expression (the third in the for) is always done at
- the end of the loop.
-
- Michael M Rubenstein
-